home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Games / Glypha 3.02 / source / Code ƒ / E-Enemies.p < prev    next >
Encoding:
Text File  |  1990-09-20  |  21.0 KB  |  778 lines  |  [TEXT/PJMM]

  1. unit Enemies;
  2.  
  3. interface
  4.     uses
  5.         Sound, GameUtils;
  6.  
  7.     procedure UpdateEye;
  8.     procedure UpdateTheHand;
  9.     procedure RetractTheHand;
  10.     procedure EnemyHitAStone (whichStone: Rect; which: Integer);
  11.     procedure DoEnemyPlacement (who: Integer);
  12.     procedure DeathToTheBeast (who: Integer);
  13.     procedure PlayerBeastCollision (who: Integer);
  14.     procedure HandleTheEnemies;
  15.  
  16. implementation
  17.  
  18. {=================================}
  19.  
  20.     procedure MoveEye;
  21.     begin
  22.         if (thePlayer.otherState) then
  23.             Exit(MoveEye);
  24.         with theEye do
  25.             begin
  26.                 if thePlayer.dest.left < dest.left then
  27.                     begin
  28.                         dest.left := dest.left - 4;
  29.                         dest.right := dest.right - 4;
  30.                     end
  31.                 else
  32.                     begin
  33.                         dest.left := dest.left + 4;
  34.                         dest.right := dest.right + 4;
  35.                     end;
  36.                 if thePlayer.dest.top < dest.top then
  37.                     begin
  38.                         dest.top := dest.top - 2;
  39.                         dest.bottom := dest.bottom - 2;
  40.                     end
  41.                 else
  42.                     begin
  43.                         dest.top := dest.top + 2;
  44.                         dest.bottom := dest.bottom + 2;
  45.                     end;
  46.             end;
  47.     end;
  48.  
  49. {=================================}
  50.  
  51.     procedure UpdateEye;
  52.         var
  53.             dummyRect, tempRect: Rect;
  54.     begin
  55.         with theEye do
  56.             begin
  57.                 case mode of
  58.                     1..3: 
  59.                         begin
  60.                             mode := mode + 1;
  61.                             otherMode := 0;
  62.                             StrikeLightning(tempInt);
  63.                         end;
  64.                     4..6: 
  65.                         begin
  66.                             mode := mode + 1;
  67.                             otherMode := 1;
  68.                         end;
  69.                     7..9: 
  70.                         begin
  71.                             mode := mode + 1;
  72.                             otherMode := 2;
  73.                         end;
  74.                     10..12: 
  75.                         begin
  76.                             mode := mode + 1;
  77.                             otherMode := 3;
  78.                         end;
  79.                     13..230: 
  80.                         begin
  81.                             mode := mode + 1;
  82.                             otherMode := 4;
  83.                             MoveEye;
  84.                         end;
  85.                     231..235: 
  86.                         begin
  87.                             mode := mode + 1;
  88.                             otherMode := 3;
  89.                             MoveEye;
  90.                         end;
  91.                     236..240: 
  92.                         begin
  93.                             mode := mode + 1;
  94.                             otherMode := 2;
  95.                             MoveEye;
  96.                         end;
  97.                     241..245: 
  98.                         begin
  99.                             mode := mode + 1;
  100.                             otherMode := 1;
  101.                             MoveEye;
  102.                         end;
  103.                     246..255: 
  104.                         begin
  105.                             mode := mode + 1;
  106.                             otherMode := 0;
  107.                             MoveEye;
  108.                         end;
  109.                     256..260: 
  110.                         begin
  111.                             mode := mode + 1;
  112.                             otherMode := 1;
  113.                             MoveEye;
  114.                         end;
  115.                     261..265: 
  116.                         begin
  117.                             mode := mode + 1;
  118.                             otherMode := 2;
  119.                             MoveEye;
  120.                         end;
  121.                     266..270: 
  122.                         begin
  123.                             mode := mode + 1;
  124.                             otherMode := 3;
  125.                             MoveEye;
  126.                         end;
  127.                     271: 
  128.                         begin
  129.                             mode := 81;
  130.                         end;
  131.                     272..275:                         {Here the eye is closing for good        }
  132.                         begin                                {The eye will never even get to a        }
  133.                             mode := mode + 1;    {mode >= 272 unless the player            }
  134.                             otherMode := 3;        {manages to hit the eye while it is    }
  135.                             MoveEye;                    {closing.                                                        }
  136.                         end;
  137.                     276..280: 
  138.                         begin
  139.                             mode := mode + 1;
  140.                             otherMode := 2;
  141.                             MoveEye;
  142.                         end;
  143.                     281..285: 
  144.                         begin
  145.                             mode := mode + 1;
  146.                             otherMode := 1;
  147.                             MoveEye;
  148.                         end;
  149.                     286..290: 
  150.                         begin
  151.                             mode := mode + 1;
  152.                             otherMode := 0;
  153.                             MoveEye;
  154.                         end;
  155.                     291: 
  156.                         begin
  157.                             UnionRect(oldDest, dest, wholeRect);
  158.                             CopyBits(offVirginMap, mainWndo^.portBits, wholeRect, wholeRect, srcCopy, playRgn);
  159.                             mode := (levelOn * 10) - 300;
  160.                             if mode > -50 then
  161.                                 mode := -50;
  162.                             dest := eyeRects[4];
  163.                             dest.left := dest.left - 80;
  164.                             dest.right := dest.right - 80;
  165.                             dest.top := dest.top + 120;
  166.                             dest.bottom := dest.bottom + 120;
  167.                             oldDest := dest;
  168.                         end;
  169.  
  170.                     otherwise
  171.                         begin
  172.                             mode := mode + 1;
  173.                             if (mode = 0) then
  174.                                 begin
  175.                                     DoTheSound('lightning.snd', TRUE);
  176.                                     dest := eyeRects[4];
  177.                                     dest.left := dest.left - 43;
  178.                                     dest.right := dest.right - 43;
  179.                                     dest.top := dest.top + 70;
  180.                                     dest.bottom := dest.bottom + 70;
  181.                                     if (DoRandom(2) = 0) then
  182.                                         begin
  183.                                             dest.top := dest.top + 100;
  184.                                             dest.bottom := dest.bottom + 100;
  185.                                             StrikeLightning(lowerEye);
  186.                                             tempInt := lowerEye;
  187.                                         end
  188.                                     else
  189.                                         begin
  190.                                             StrikeLightning(upperEye);
  191.                                             tempInt := upperEye;
  192.                                         end;
  193.                                     oldDest := dest;
  194.                                 end;
  195.                             Exit(UpdateEye);
  196.                         end;
  197.                 end;
  198.                 tempRect := dest;
  199.                 InsetRect(tempRect, 10, 5);
  200.                 if SectRect(tempRect, thePlayer.dest, dummyRect) then
  201.                     begin
  202.                         if otherMode = 4 then                {The player is DEAD!            }
  203.                             begin
  204.                                 thePlayer.otherState := TRUE;
  205.                                 DoTheSound('bird.snd', TRUE);
  206.                             end
  207.                         else if (mode <> 291) then    {The player killed the eye!!!    }
  208.                             begin
  209.                                 DoTheSound('bonus.snd', TRUE);
  210.                                 score := score + 2000;
  211.                                 CheckExtraMortal;
  212.                                 mode := 291;
  213.                                 UnionRect(oldDest, dest, wholeRect);
  214.                                 CopyBits(offVirginMap, mainWndo^.portBits, wholeRect, wholeRect, srcCopy, playRgn);
  215.                             end;
  216.                     end;
  217.             end;
  218.     end;
  219.  
  220. {=================================}
  221.  
  222.     procedure UpdateTheHand;
  223.         var
  224.             dummyRect, tempRect: Rect;
  225.     begin
  226.         if ((levelOn < 3) or (stonesSliding)) then
  227.             Exit(UpdateTheHand);
  228.         with theHand do
  229.             begin
  230.                 state := TRUE;
  231.                 if mode = 0 then
  232.                     begin
  233.                         if (thePlayer.dest.left < dest.left) then
  234.                             begin
  235.                                 dest.left := dest.left - 6;
  236.                                 dest.right := dest.right - 6;
  237.                             end
  238.                         else
  239.                             begin
  240.                                 dest.left := dest.left + 6;
  241.                                 dest.right := dest.right + 6;
  242.                             end;
  243.  
  244.                         if (thePlayer.dest.bottom < dest.top) then
  245.                             begin
  246.                                 dest.top := dest.top - 3;
  247.                                 dest.bottom := dest.bottom - 3;
  248.                             end
  249.                         else
  250.                             begin
  251.                                 dest.top := dest.top + 1;
  252.                                 dest.bottom := dest.bottom + 1;
  253.                             end;
  254.  
  255.                         tempRect := dest;
  256.                         tempRect.right := tempRect.left + 40;
  257.                         if SectRect(tempRect, thePlayer.dest, dummyRect) and (thePlayer.dest.left < dest.left + 40) then
  258.                             begin
  259.                                 DoTheSound('bird.snd', TRUE);
  260.                                 mode := 1;
  261.                                 OffsetRect(thePlayer.dest, dest.left - thePlayer.dest.left - (thePlayer.facing * 25), dest.top - thePlayer.dest.bottom);
  262.                                 thePlayer.horiVel := 0;
  263.                                 thePlayer.vertVel := 0;
  264.                                 oldDirection := thePlayer.facing;
  265.                             end;
  266.                     end
  267.                 else
  268.                     begin
  269.                         OffsetRect(thePlayer.dest, (oldDirection - thePlayer.facing) * 25 - thePlayer.horiVel, -thePlayer.vertVel);
  270.                         if (thePlayer.vertVel < 0) and (DoRandom(levelOn div 5) = 0) then
  271.                             begin
  272.                                 dest.top := dest.top - 2;
  273.                                 dest.bottom := dest.bottom - 2;
  274.                                 thePlayer.dest.top := thePlayer.dest.top - 2;
  275.                                 thePlayer.dest.bottom := thePlayer.dest.bottom - 2;
  276.                             end
  277.                         else if (thePlayer.vertVel >= 0) then
  278.                             begin
  279.                                 dest.top := dest.top + 1;
  280.                                 dest.bottom := dest.bottom + 1;
  281.                                 thePlayer.dest.top := thePlayer.dest.top + 1;
  282.                                 thePlayer.dest.bottom := thePlayer.dest.bottom + 1;
  283.                             end;
  284.                         thePlayer.horiVel := 0;
  285.                         thePlayer.vertVel := 0;
  286.                         oldDirection := thePlayer.facing;
  287.                     end;
  288.                 if dest.top < 275 then
  289.                     begin
  290.                         dest.top := 275;
  291.                         mode := 0;
  292.                     end;
  293.                 DrawHand;
  294.                 oldDest := dest;
  295.             end;
  296.     end;
  297.  
  298. {=================================}
  299.  
  300.     procedure RetractTheHand;
  301.     begin
  302.         with theHand do
  303.             begin
  304.                 mode := 0;
  305.                 dest.top := dest.top + 1;
  306.                 dest.bottom := dest.bottom + 1;
  307.                 if dest.top > 337 then
  308.                     state := FALSE;
  309.                 DrawHand;
  310.                 oldDest := dest;
  311.             end;
  312.     end;
  313.  
  314. {=================================}
  315.  
  316.     procedure EnemyHitAStone;
  317.         var
  318.             hori, vert: Integer;
  319.     begin
  320.         with theEnemies[which] do
  321.             begin
  322.                 if (horiVel > 0) then
  323.                     begin
  324.                         if (dest.left < whichStone.left) then    {hit the edge}
  325.                             begin
  326.                                 dest.left := dest.left + whichStone.left - whichStone.right;
  327.                                 dest.right := dest.right + whichStone.left - whichStone.right;
  328.                                 horiVel := impacted[horiVel];
  329.                             end
  330.                         else
  331.                             begin
  332.                                 if (vertVel < 0) then        {hit coming up}
  333.                                     begin
  334.                                         vertVel := impacted[vertVel];
  335.                                         dest.bottom := dest.bottom + whichStone.bottom - dest.top;
  336.                                         dest.top := dest.top + whichStone.bottom - dest.top;
  337.                                     end
  338.                                 else
  339.                                     begin
  340.                                         if (mode < -1) then
  341.                                             begin
  342.                                                 horiVel := (horiVel * 2) div 3;
  343.                                                 vertVel := impacted[vertVel];
  344.                                                 if (ABS(vertVel) < 3) then
  345.                                                     begin
  346.                                                         vertVel := 0;
  347.                                                         horiVel := 0;
  348.                                                         otherState := TRUE;
  349.                                                     end;
  350.                                                 dest.top := dest.top + whichStone.top - dest.bottom;
  351.                                                 dest.bottom := dest.bottom + whichStone.top - dest.bottom;
  352.                                                 Exit(EnemyHitAStone);
  353.                                             end;
  354.                                         if (vertVel < 4) or (dest.right > whichStone.right) then
  355.                                             begin
  356.                                                 vertVel := -3;
  357.                                                 dest.top := dest.top + whichStone.top - dest.bottom;
  358.                                                 dest.bottom := dest.bottom + whichStone.top - dest.bottom;
  359.                                             end
  360.                                         else
  361.                                             begin
  362.                                                 vertVel := 0;
  363.                                                 dest.top := dest.top + whichStone.top - dest.bottom - 10;
  364.                                                 dest.bottom := dest.bottom + whichStone.top - dest.bottom - 10;
  365.                                                 mode := 1;
  366.                                                 hori := dest.left;
  367.                                                 vert := dest.top;
  368.                                                 SetRect(dest, 0, 0, 41, 42);
  369.                                                 dest.top := dest.top + vert;
  370.                                                 dest.bottom := dest.bottom + vert;
  371.                                                 dest.left := dest.left + hori;
  372.                                                 dest.right := dest.right + hori;
  373.                                             end;
  374.                                     end;
  375.                             end;
  376.                     end
  377.                 else
  378.                     begin
  379.                         if (dest.right > whichStone.right) then    {hit the edge}
  380.                             begin
  381.                                 dest.left := dest.left + whichStone.right - whichStone.left;
  382.                                 dest.right := dest.right + whichStone.right - whichStone.left;
  383.                                 horiVel := impacted[horiVel];
  384.                             end
  385.                         else
  386.                             begin
  387.                                 if (vertVel < 0) then        {hit coming up}
  388.                                     begin
  389.                                         vertVel := impacted[vertVel];
  390.                                         dest.bottom := dest.bottom + whichStone.bottom - dest.top;
  391.                                         dest.top := dest.top + whichStone.bottom - dest.top;
  392.                                     end
  393.                                 else
  394.                                     begin
  395.                                         if (mode < -1) then
  396.                                             begin
  397.                                                 horiVel := (horiVel * 2) div 3;
  398.                                                 vertVel := impacted[vertVel];
  399.                                                 if (ABS(vertVel) < 3) then
  400.                                                     begin
  401.                                                         horiVel := 0;
  402.                                                         vertVel := 0;
  403.                                                         otherState := TRUE;
  404.                                                     end;
  405.                                                 dest.top := dest.top + whichStone.top - dest.bottom;
  406.                                                 dest.bottom := dest.bottom + whichStone.top - dest.bottom;
  407.                                                 Exit(EnemyHitAStone);
  408.                                             end;
  409.                                         if (vertVel < 4) or (dest.left < whichStone.left) then
  410.                                             begin
  411.                                                 vertVel := -3;
  412.                                                 dest.top := dest.top + whichStone.top - dest.bottom;
  413.                                                 dest.bottom := dest.bottom + whichStone.top - dest.bottom;
  414.                                             end
  415.                                         else
  416.                                             begin
  417.                                                 vertVel := 0;
  418.                                                 dest.top := dest.top + whichStone.top - dest.bottom - 10;
  419.                                                 dest.bottom := dest.bottom + whichStone.top - dest.bottom - 10;
  420.                                                 mode := 1;
  421.                                                 hori := dest.left;
  422.                                                 vert := dest.top;
  423.                                                 SetRect(dest, 0, 0, 41, 42);
  424.                                                 dest.top := dest.top + vert;
  425.                                                 dest.bottom := dest.bottom + vert;
  426.                                                 dest.left := dest.left + hori;
  427.                                                 dest.right := dest.right + hori;
  428.                                             end;
  429.                                     end;
  430.                             end;
  431.                     end;
  432.             end;
  433.     end;
  434.  
  435. {=================================}
  436.  
  437.     procedure DoEnemyPlacement;
  438.         var
  439.             aNumber: Integer;
  440.     begin
  441.         with theEnemies[who] do
  442.             begin
  443.                 otherState := FALSE;
  444.                 facing := DoRandom(2);
  445.                 aNumber := DoRandom(2);
  446.                 if (((levelOn + 1) div 5) = ((levelOn + 1) / 5)) then
  447.                     aNumber := 1;
  448.                 if facing = 0 then
  449.                     begin
  450.                         if aNumber = 0 then
  451.                             SetRect(dest, 50, 96, 91, 96)
  452.                         else
  453.                             SetRect(dest, 50, 212, 91, 212);
  454.                     end
  455.                 else
  456.                     begin
  457.                         if aNumber = 0 then
  458.                             SetRect(dest, 430, 96, 471, 96)
  459.                         else
  460.                             SetRect(dest, 430, 212, 471, 212);
  461.                     end;
  462.                 oldDest := dest;
  463.             end;
  464.     end;
  465. {=================================}
  466.  
  467.     procedure DeathToTheBeast;
  468.         var
  469.             tempRect: Rect;
  470.     begin
  471.         with theEnemies[who] do
  472.             begin
  473.                 UnionRect(oldDest, dest, wholeRect);
  474.                 CopyBits(offVirginMap, mainWndo^.portBits, wholeRect, wholeRect, srcCopy, playRgn);
  475.                 mode := DoRandom(50) + 50;
  476.                 vertVel := 0;
  477.                 horiVel := 0;
  478.                 DoEnemyPlacement(who);
  479.                 if (state) and (otherMode > 0) then
  480.                     begin
  481.                         otherMode := otherMode - 1;
  482.                         state := FALSE;
  483.                     end;
  484.                 beastsKilled := beastsKilled + 1;
  485.                 beastsActive := beastsActive - 1;
  486.                 if (beastsKilled >= totalToKill) then
  487.                     begin
  488.                         onward := TRUE;
  489.                     end;
  490.             end;
  491.     end;
  492.  
  493. {=================================}
  494.  
  495.     procedure PlayerBeastCollision;
  496.         var
  497.             hori, vert: Integer;
  498.             tempRect: Rect;
  499.     begin
  500.         with theEnemies[who] do
  501.             begin
  502.                 if (mode < 0) then    {You hit the enemy while in egg form!    }
  503.                     begin
  504.                         DoTheSound('boom1.snd', TRUE);
  505.                         DeathToTheBeast(who);                        {So, get the beast killed and reset        }
  506.                         score := score + 500;                        {That's 500 points for the player            }
  507.                         CheckExtraMortal;
  508.                         Exit(PlayerBeastCollision);            {All we need here                            }
  509.                     end;
  510.                 if ((thePlayer.dest.top > dest.top + 1) and (not thePlayer.otherState) and (mode > -1)) then
  511.                     begin                                                            {The beast killed you!    }
  512.                         thePlayer.otherState := TRUE;        {The player is dead        }
  513.                         DoTheSound('boom2.snd', TRUE);    {Make that death sound    }
  514.                     end
  515.                 else
  516.                     begin
  517.                         if (dest.top > thePlayer.dest.top + 2) then
  518.                             begin                                                    {The player killed the beast!!!            }
  519.                                 score := score + 500 + (500 * otherMode);    {Score based on what sphinx model    }
  520.                                 CheckExtraMortal;
  521.                                 if (otherMode < 2) then
  522.                                     begin
  523.                                         otherMode := otherMode + 1;        {Bump up the sphinx model        }
  524.                                         state := TRUE;                                {Let program remember this    }
  525.                                     end;
  526.                                 DoTheSound('boom2.snd', TRUE);        {Make that big boom sound        }
  527.                                 mode := DoRandom(200) - 350;            {Enemy becomes an egg                }
  528.                                 hori := dest.left;
  529.                                 vert := dest.top;
  530.                                 SetRect(dest, 0, 0, 23, 23);
  531.                                 if (vertVel <> 0) then
  532.                                     begin
  533.                                         dest.top := dest.top + vert + 25;
  534.                                         dest.bottom := dest.bottom + vert + 25;
  535.                                         dest.left := dest.left + hori;
  536.                                         dest.right := dest.right + hori;
  537.                                     end
  538.                                 else
  539.                                     begin
  540.                                         dest.top := dest.top + vert;
  541.                                         dest.bottom := dest.bottom + vert;
  542.                                         dest.left := dest.left + hori;
  543.                                         dest.right := dest.right + hori;
  544.                                     end;
  545.                             end
  546.                         else
  547.                             begin                                                            {close - they bounced off each other    }
  548.                                 DoTheSound('screech.snd', TRUE);                        {Make that screeching sound            }
  549.                                 horiVel := impacted[horiVel];
  550.                                 thePlayer.horiVel := impacted[thePlayer.horiVel];
  551.                             end;
  552.                     end;
  553.             end;
  554.     end;
  555.  
  556. {=================================}
  557.  
  558.     procedure HandleTheEnemies;
  559.         var
  560.             onLand: Boolean;
  561.             index, loop, hori, vert: Integer;
  562.             dummyLong: LongInt;
  563.             tempRect, dummyRect: Rect;
  564.     begin
  565.         for loop := 1 to numberOfEnemies do
  566.             with theEnemies[loop] do
  567.                 begin
  568.                     case mode of
  569.                         -600..-2:    {egg stage - hasn't hatched yet}
  570.                             begin
  571.                                 mode := mode + 1;
  572.                                 if (mode = -1) then
  573.                                     DoTheSound('spawn.snd', TRUE);
  574.                                 if (otherState) then                    {Has the egg stopped falling?}
  575.                                     begin
  576.                                         horiVel := horiVel * 2 div 3;
  577.                                         onLand := FALSE;
  578.                                         tempRect := dest;
  579.                                         tempRect.left := tempRect.left + 10;
  580.                                         tempRect.right := tempRect.right - 10;
  581.                                         tempRect.top := tempRect.top + 2;
  582.                                         tempRect.bottom := tempRect.bottom + 2;
  583.  
  584.                                         for index := startStone to numberOfStones do
  585.                                             if (SectRect(tombRects[index], tempRect, dummyRect)) then
  586.                                                 onLand := TRUE;
  587.                                         if (not onLand) then
  588.                                             begin
  589.                                                 otherState := FALSE;
  590.                                                 vertVel := fallAmount;
  591.                                             end;
  592.                                     end
  593.                                 else
  594.                                     begin
  595.                                         if (vertVel < (maxFall div 3)) then
  596.                                             vertVel := vertVel + fallAmount;
  597.                                         for index := startStone to numberOfStones do
  598.                                             if SectRect(dest, tombRects[index], dummyRect) then
  599.                                                 EnemyHitAStone(dummyRect, loop);
  600.                                     end;
  601.                                 dest.left := dest.left + horiVel;
  602.                                 dest.right := dest.right + horiVel;
  603.                                 dest.top := dest.top + vertVel;
  604.                                 dest.bottom := dest.bottom + vertVel;
  605.                             end;
  606.  
  607.                         -1:         {egg hatches!!!}
  608.                             begin
  609.                                 dest.top := dest.top + growRate;
  610.                                 if (dest.top >= dest.bottom) then
  611.                                     begin
  612.                                         dest.top := dest.bottom;
  613.                                         dest.right := dest.left + 41;
  614.                                         dest.left := dest.left - 10;
  615.                                         dest.right := dest.right - 10;
  616.                                         otherState := FALSE;
  617.                                         mode := 6;
  618.                                     end;
  619.                             end;
  620.  
  621.                         0..2:    {if running along the ground}
  622.                             begin
  623.                                 onLand := FALSE;                                    {First, we assume the enemy is}
  624.                                 tempRect.left := dest.left + 17;    {no longer on land.  Then we test}
  625.                                 tempRect.right := dest.right - 17;{the enemies rect to see if it is}
  626.                                 tempRect.top := dest.top + 2;            {intersecting the ground.}
  627.                                 tempRect.bottom := dest.bottom + 2;
  628.  
  629.                                 for index := startStone to numberOfStones do
  630.                                     if (SectRect(tombRects[index], tempRect, dummyRect)) then
  631.                                         onLand := TRUE;                    {Yes, enemy is still on land.}
  632.                                 if (not onLand) or (DoRandom(6) = 0) then
  633.                                     begin                                            {If enemy is'nt still on the ledge...}
  634.                                         mode := 4;
  635.                                         dest.right := dest.left + 67;
  636.                                         dest.bottom := dest.top + 36;
  637.                                         vertVel := fallAmount;
  638.                                     end
  639.                                 else                {in fact, we're on solid ground after all}
  640.                                     begin
  641.                                         horiVel := running[horiVel, facing, 0];
  642.                                         mode := running[horiVel, facing, 1];
  643.                                     end;
  644.  
  645.                                 dest.left := dest.left + horiVel;
  646.                                 dest.right := dest.right + horiVel;
  647.                                 dest.top := dest.top + vertVel;
  648.                                 dest.bottom := dest.bottom + vertVel;
  649.                             end;
  650.  
  651.                         4..5:                    {else, the dude is in the air}
  652.                             begin
  653.                                 horiVel := gliding[horiVel, facing];
  654.  
  655.                                 if ((thePlayer.dest.top > dest.top - 150) and (thePlayer.dest.top < dest.top + 20)) and (not thePlayer.otherState) then
  656.                                     begin            {the dude's gonna flap and turn to face you}
  657.                                         mode := 5;
  658.                                         vertVel := vertVel + enemyLift[otherMode];
  659.                                         if (thePlayer.dest.left < dest.left) then
  660.                                             facing := 1
  661.                                         else
  662.                                             facing := 0;
  663.                                     end
  664.                                 else
  665.                                     begin
  666.                                         if ((thePlayer.dest.top > dest.top + 20) and (not thePlayer.otherState) and (vertVel < maxFall)) then
  667.                                             begin
  668.                                                 vertVel := vertVel + fallAmount;
  669.                                             end
  670.                                         else
  671.                                             begin
  672.                                                 if (vertVel > 8) or (dest.bottom > 290) or (DoRandom(4) = 0) then
  673.                                                     begin            {the dude's also gonna flap}
  674.                                                         mode := 5;
  675.                                                         vertVel := vertVel + enemyLift[otherMode];
  676.                                                     end
  677.                                                 else                {the dude instead is just gliding}
  678.                                                     begin
  679.                                                         mode := 4;
  680.                                                         if (vertVel < maxFall) then
  681.                                                             vertVel := vertVel + fallAmount;
  682.                                                     end;
  683.                                             end;
  684.                                     end;
  685.  
  686.                                 dest.left := dest.left + horiVel;
  687.                                 dest.right := dest.right + horiVel;
  688.                                 dest.top := dest.top + vertVel;
  689.                                 dest.bottom := dest.bottom + vertVel;
  690.  
  691.                                 for index := startStone to numberOfStones do
  692.                                     begin
  693.                                         if SectRect(dest, tombRects[index], dummyRect) then
  694.                                             EnemyHitAStone(dummyRect, loop);
  695.                                     end;
  696.                             end;
  697.  
  698.                         6: 
  699.                             begin
  700.                                 dest.top := dest.top - growRate;
  701.                                 if ((dest.bottom - dest.top) >= 43) then
  702.                                     begin
  703.                                         dest.top := dest.bottom - 43;
  704.                                         mode := 0;
  705.                                     end;
  706.                             end;
  707.  
  708.                         7: 
  709.                             begin
  710.                                 if (beastsKilled + beastsActive) < totalToKill then
  711.                                     begin
  712.                                         DoTheSound('spawn.snd', TRUE);
  713.                                         beastsActive := beastsActive + 1;
  714.                                         mode := 6;
  715.                                     end
  716.                                 else
  717.                                     mode := 500;
  718.                             end;
  719.  
  720.                         8..500: 
  721.                             mode := mode - 1;
  722.  
  723.                         otherwise
  724.                             begin
  725.                                 mode := mode - 1;
  726.                             end;
  727.                     end;                    {end - case Mode}
  728.  
  729.                     if ((not SectRect(dest, playRect, dummyRect)) and (mode <> 6)) and (mode <> -1) then
  730.                         begin
  731.                             if (dest.top > playRect.bottom) then
  732.                                 begin
  733.                                     DoTheSound('drip.snd', TRUE);
  734.                                     DeathToTheBeast(loop);
  735.                                 end
  736.                             else if (dest.top <= 0) then
  737.                                 begin
  738.                                     vertVel := impacted[vertVel];
  739.                                     dest.bottom := dest.bottom - dest.top;
  740.                                     dest.top := 0;
  741.                                 end;
  742.  
  743.                             if (dest.right < playRect.left) then        {Wraparound routines    }
  744.                                 begin
  745.                                     CopyBits(offVirginMap, mainWndo^.portBits, oldDest, oldDest, srcCopy, playRgn);
  746.                                     dest.right := dest.right + 500;
  747.                                     dest.left := dest.left + 500;
  748.                                     oldDest := dest;
  749.                                 end
  750.                             else if (dest.left > playRect.right) then
  751.                                 begin
  752.                                     CopyBits(offVirginMap, mainWndo^.portBits, oldDest, oldDest, srcCopy, playRgn);
  753.                                     dest.left := dest.left - 500;
  754.                                     dest.right := dest.right - 500;
  755.                                     oldDest := dest;
  756.                                 end;
  757.                         end;        {if not SectRect}
  758.  
  759.                     tempRect := dest;
  760.                     if (mode >= 0) then
  761.                         InsetRect(tempRect, 16, 6);
  762.                     if (SectRect(tempRect, thePlayer.dest, dummyRect) and (not thePlayer.otherState)) then
  763.                         PlayerBeastCollision(loop);
  764.  
  765.                 end;                    {end - for loop}
  766.  
  767.         if (delayFor <> 0) then
  768.             begin
  769.                 lastLoopTime := lastLoopTime + delayFor;
  770.                 repeat
  771.                 until (TickCount >= lastLoopTime);
  772.                 lastLoopTime := TickCount;
  773.             end;
  774.     end;
  775.  
  776. {=================================}
  777.  
  778. end.